using INTEX.DataBase;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class VBABST
    {

        public void NEWVWBB(Dictionary<string, object> pm)
        {
            dwData = TBMain.NewRow();
            SetUpNewRow(ref dwData);
            ORDERNUM = (string)pm["ORDERNUM"];
            double _QTYEND = Convert.ToDouble(pm["QTYEND"].ToString());
            double _QTYMAT = Convert.ToDouble(pm["QTYMAT"].ToString());
            double QTY = _QTYMAT;
           

            string BKRS = "SZ";
            string BLFD = "";
            double WLeng = Convert.ToDouble(pm["QTYEND"].ToString());
            int BAANZ1 = Convert.ToInt16(pm["JNUM"].ToString());
            if (BAANZ1 <= 0)
                BAANZ1 = 1;
            double ABPSOLLMENGE5 = Convert.ToDouble(pm["ABPSOLLMENGE5"].ToString());
            double BMSOLLLG=0, BMSOLLGEW=0;
            BMSOLLLG = System.Math.Round(WLeng / BAANZ1, 0);
            BMSOLLGEW = System.Math.Round(ABPSOLLMENGE5 * 10 / BAANZ1, 0);
            for (int bi = 0; bi < BAANZ1; bi++)
            {
                dwData["BMBAUMKRS"] = BKRS;
                dwData["BMBAUMLFD"] = VSDDAT.SD22.GETNEXT("0022", BKRS, "  ", 2, 6);
                dwData["BMKART"] = pm["ART"].ToString();
                dwData["BMKVAR"] = pm["VAR"].ToString().Trim().PadRight(2);
                dwData["BMFARBE"] = pm["FARBE"].ToString();
                dwData["BMAUFKRS"] = ORDERNUM.Substring(0, 2);
                dwData["BMAUFLFD"] = ORDERNUM.Substring(2, 6);
                dwData["BMAUFPOS"] = ORDERNUM.Substring(8, 3);
                dwData["BMFDZ"] = "3844";
                dwData["BMKETTTYP"] = "01    ";
                dwData["BMSA"] = "320";
                dwData["BMAUFTYP"] = "V";
                dwData["BMFERTKZ"] = "E";
                dwData["BMPRODLO"] = pm["PRLO"];
                dwData["BMPRODLB"] = pm["PRLB"];
                dwData["BMPRODLP"] = pm["PRLP"];
                dwData["BMDATERL"] = "0";
                dwData["BMSOLLKZ"] = " ";
                dwData["BMSOLLLG"] = BMSOLLLG;
                dwData["BMSOLLGEW"] = BMSOLLGEW;
                Insert(dwData);
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
            }
        }
        public void Insert(DataRow _dwGD)
        {

            InsertBABST(_dwGD);
            TBMain.Rows.InsertAt(_dwGD, 0);
        }
    }
}
